<?php 


/** 
***************************************************
*欢迎使用免费版xSite企业自助建站软件！
*这是一个专业为搜索引擎营销而设计的，极稳定、极易维护的建站软件！
*官方客服：help@php.net.cn
*官方下载网址：http://www.php.net.cn/xsite/ 
***************************************************
**/




if (!@set_time_limit (0)) { @ini_set('max_execution_time', 3600); } if (function_exists('date_default_timezone_set')) { date_default_timezone_set('PRC'); } define('ALLOW_URL_FOPEN', ini_get('allow_url_fopen')); if (!ALLOW_URL_FOPEN) { exit('由于你的PHP主机关才了远程访问功能，所以无法使用升级程序，请将你空间的php.ini设置中的“allow_url_fopen”改为“ON”或“1”<br /><br />推荐你从<a href = "http://www.php.net.cn/host/ " target="_blank">http://www.php.net.cn/host/ </a>购买专业php主机'); } define('UPDATE_ROOT', str_replace('\\', '/', dirname(__FILE__))); define('SITE_ROOT', UPDATE_ROOT . "/php.net.cn/xsite"); define("IN_SITETEAM", true); require_once UPDATE_ROOT . "/php.net.cn/xsite/include/global.inc.php"; require_once UPDATE_ROOT . "/php.net.cn/xsite/include/update.inc.php"; require_once SITE_ROOT . "/admin/admin.inc.php"; session_save_path(UPDATE_ROOT . "/php.net.cn/xsite/data/log"); session_set_cookie_params(time() + 3600); session_name('siteteam'); session_start(); if (!isset($_SESSION['loginid'])) { exit('你没有操作权限'); } $action = empty($_GET['action']) ? empty($_POST['action']) ? '' : $_POST['action'] : $_GET['action']; $updatefile = UPDATE_ROOT . "/xsite.zip"; if (in_array($action, array('version', 'two', 'unpack_update_file', 'downzip'))) { if (!file_exists(SITE_ROOT . "/data/version.txt")) { $c_version = ''; } else { $c_version = read_array_file(SITE_ROOT . "/data/version.txt"); } if ($s_version = @file(Data_API('/xsite/version.php'))) { $s_version = implode('', $s_version); $s_version = unserialize(base64_decode($s_version)); } else { $s_version = ''; } } if ($action == "version") { include SITE_ROOT . "/admin/tpl/version.tpl.php"; } if ($action == "two") { include SITE_ROOT . "/admin/tpl/version.tpl.php"; } if ($action == "downzip") { if (preg_match('/set_time_limit/is', get_cfg_var("disable_functions")) && ini_get('max_execution_time') < 90) { $xsite_update_info = array(); $xsite_update_info['filename'] = $remote_zip = xsite_update_zip(); $headers = (get_headers($remote_zip, 1)); if (isset($headers['Content-Length'])) { $byte_length = intval($headers['Content-Length']); } else { $byte_length = $s_version['size']; } $xsite_update_info['byte_length'] = $byte_length; $xsite_update_info['md5'] = $s_version['md5'];; save_array_to_file($xsite_update_info, SITE_ROOT . '/data/cache/xsite_update_info.php', 'xsite_update_info'); if (file_exists('xsite.zip')) { fclose(fopen('xsite.zip', 'w')); } } include SITE_ROOT . "/admin/tpl/version.tpl.php"; } if ($action == "get_update_file_ajax") { if (file_exists(SITE_ROOT . '/data/cache/xsite_update_info.php')) { include SITE_ROOT . '/data/cache/xsite_update_info.php'; $temp = intval(@filesize('xsite.zip')); if ($temp < $xsite_update_info['byte_length']) { $download_server = Data_API('/xsite/download_server.php'); $byte_code = file_get_contents("{$download_server}?action=xsite&start={$temp}&byte=" . (1024 * 64) ); if ($byte_code != false) { $fp = fopen('xsite.zip', 'a'); fwrite($fp, $byte_code); fclose($fp); echo '1'; } else { echo '3'; } } elseif ($temp >= $xsite_update_info['byte_length']) { echo '8'; } } else { echo '4'; } } if ($action == "unpack_update_file") { require_once SITE_ROOT . "/admin/zip.inc.php"; if (md5_file("xsite.zip") != $s_version['md5']) { message("update.php?action=version", "升级程序不能解压，你网站根目录中的xsite.zip与官方发布的不一致！"); } $reportfile = SITE_ROOT . '/data/update.log'; $updatelog = fopen($reportfile, "w+"); if (!function_exists('zip_open')) { $oU = new SimpleUnzip('xsite.zip'); $bF = FALSE; foreach($oU->Entries as $oI) { if ($oI->Name == 'domain.php') continue; $zip_dir = '.' . substr($oI->Path, 5); if (!@file_exists($zip_dir)) { file_mkdir($zip_dir); } if (!empty($oI->Data)) { $fp = @fopen("{$zip_dir}/" . $oI->Name, "wb+"); if ($fp) { fwrite($fp, $oI->Data); fclose($fp); @fwrite($updatelog, "\r\nOK:{$zip_dir}/" . $oI->Name); } else { @fwrite($updatelog, "\r\nError:{$zip_dir}/" . $oI->Name); } } $bF = TRUE; } } else { $zip = zip_open("xsite.zip"); if ($zip) { while ($zip_entry = zip_read($zip)) { $file_name = zip_entry_name($zip_entry); if (preg_match('/^xsite\//is', $file_name)) { $file_name = substr($file_name, 6); } if ($file_name == '' || preg_match('/domain\.php$/is', $file_name)) { continue; } if (zip_entry_open($zip, $zip_entry)) { if (preg_match('/\/$/is', $file_name)) { if (!file_exists($file_name)) { file_mkdir($file_name); } } else { $file_dir = dirname($file_name); if ($file_dir != '.' && $file_dir != '..' && !file_exists($file_dir)) { file_mkdir($file_dir); } $size = zip_entry_filesize($zip_entry); if(($fp = @fopen($file_name, 'wb'))) { if ($size > 0) { fwrite($fp, zip_entry_read($zip_entry, $size)); } @fwrite($updatelog, "\r\nOK:{$file_name}"); fclose($fp); } else { @fwrite($updatelog, "\r\nError:{$file_name}/"); } } zip_entry_close($zip_entry); } } zip_close($zip); } } fclose($updatelog); $c_version = $s_version; save_array_file($c_version, SITE_ROOT. "/data/version.txt"); if (file_exists(SITE_ROOT . "/data/cache/version.txt")) { unlink(SITE_ROOT . "/data/cache/version.txt"); } session_destroy(); message("xsite.php?action=login", "升级完成了！请重新登录后台！", "top"); } ?>